home *** CD-ROM | disk | FTP | other *** search
- /**
- Checkout.c
-
- Part of the Adobe After Effects 3.1 SDK.
- (c) 1994-96, Adobe Systems Inc.
- All Rights Reserved.
-
- This effect splits a layer in two. In the bottom half, it displays the
- current layer at the current time. In the top half, it displays a user-
- specifiable layer at a user-specifiable time.
-
- This demonstrates:
- Using a Slider control.
- Using a Layer control.
- Checking out parameters at times other than the current time.
- Using the PF_COPY callback routines.
-
- Revision History
- 1.0, Created by dmw, 13 Jan 94
- 1.1, Mac/PowerMac version, dmw, 13 Oct 94
- 2.0, Updated for AE 3.0, dmw, 18 Oct 95
- 2.1, Added call to AEFX_CLR_STRUCT macro to clear out PF_ParamDef, ba, 6 Nov 96
- **/
-
- #include "AE_EffectCB.h"
- #include "AE_Macros.h"
- #include <A4Stuff.h>
-
- /**
- ** Here we #define our version values for use in the PF_VERSION
- ** macro. After Effects uses these values to determine which
- ** plug-in to run if it finds multiple version of the same effect
- ** on the user's drive.
- **/
- #define MAJOR_VERSION 2
- #define MINOR_VERSION 0
- #define BUG_VERSION 0
- #define STAGE_VERSION PF_Stage_RELEASE
- #define BUILD_VERSION 0
-
-
- /**
- ** Some more useful #define's
- **
- **/
- #define NAME "Checkout"
- #define DESCRIPTION \
- "Demonstrates checking out layers at other times. (c) 1994-96 Adobe Systems Inc."
-
-
- /** Parameter Definition Constants
-
- Here we define the parameters, their default
- settings, and minimum and maximum values.
-
- **/
-
- enum {
- CHECK_INPUT = 0,
- CHECK_FRAME,
- CHECK_LAYER,
-
- CHECK_NUM_PARAMS
- };
-
- #define CHECK_FRAME_MIN 0
- #define CHECK_FRAME_MAX 100
- #define CHECK_FRAME_DFLT 0
-
-
- /** Command Specific Subroutines
-
- This plug-in only deals with the commands:
- PF_Cmd_ABOUT
- PF_Cmd_GLOBAL_SETUP
- PF_Cmd_PARAMS_SETUP
- PF_Cmd_RENDER
- All other commands are ignored. There is a routine for
- each command, and a main routine to dispatch at the bottom.
-
- There is no PF_Cmd_GLOBAL_SETDOWN because I don't allocate
- any memory in GLOBAL_SETUP, so I don't have any cleanup to do.
-
- **/
-
- static PF_Err About (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_SPRINTF(out_data->return_msg,
- "%s, v%d.%d\r" DESCRIPTION ,
- NAME, MAJOR_VERSION, MINOR_VERSION);
-
- return PF_Err_NONE;
- }
-
-
- static PF_Err GlobalSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
-
- /* Need to let AE know what version of the "Checkout" plug-in
- * we are.
- */
- out_data->my_version = PF_VERSION(MAJOR_VERSION, MINOR_VERSION,
- BUG_VERSION, STAGE_VERSION, BUILD_VERSION);
-
- /* This effect checks out parameters at times other than the current time,
- * so I let AE know this by setting the PF_OutFlag_WIDE_TIME_INPUT flag.
- */
- out_data->out_flags |= PF_OutFlag_WIDE_TIME_INPUT;
-
- return err;
- }
-
-
- static PF_Err ParamsSetup (
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- PF_ParamDef def; /* scratch space for a parameter definition */
-
- /* Always clear out the PF_ParamDef structure before adding your parameters,
- * this macro will do that.
- */
- AEFX_CLR_STRUCT(def);
-
- /* Create the SLIDER parameter... */
-
- def.param_type = PF_Param_SLIDER;
- PF_STRCPY(def.name, "Time to checkout");
-
- /* NOTE: we must set these strings to empty strings to prevent
- * garbage text from being displayed above our sliders...
- */
- def.u.sd.value_str[0] = '\0';
- def.u.sd.value_desc[0] = '\0';
-
- /* The min and max values of the slider and the min and max
- * values the user can type will be the same value...
- */
- def.u.sd.valid_min = def.u.sd.slider_min = CHECK_FRAME_MIN;
- def.u.sd.valid_max = def.u.sd.slider_max = CHECK_FRAME_MAX;
- def.u.sd.value = def.u.sd.dephault = 0;
- if (err = PF_ADD_PARAM(in_data, -1, &def)) return err;
-
- /* Create the LAYER parameter... */
-
- def.param_type = PF_Param_LAYER;
- PF_STRCPY(def.name, "Layer to checkout");
-
- /* make the default layer setting to be "none." Could also make it
- * PF_LayerDefault_MYSELF
- */
- def.u.ld.dephault = PF_LayerDefault_NONE;
-
- if (err = PF_ADD_PARAM(in_data, -1, &def)) return err;
-
- /* Set number of parameters before leaving */
-
- out_data->num_params = CHECK_NUM_PARAMS;
-
- return err;
- }
-
-
- /** Render
- **
- **/
-
- static PF_Err Render(
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- PF_Err err2;
- long frame;
- Rect halfsies;
-
- PF_ParamDef checkout; /* put the ParamDef on the stack; will be checking one out later */
-
- /* set the halfsies rectangle to be the top half of the layer */
-
- halfsies.top = halfsies.left = 0;
- halfsies.right = output->width;
- halfsies.bottom = output->height / 2;
-
- /* frame is the slider value, an integer. I'll use this for the time value to
- * check out a frame at (frame/30) seconds
- */
- frame = params[CHECK_FRAME]->u.sd.value;
-
- /* check out the parameter CHECK_LAYER at time (frame/30) seconds with a shutter
- * duration of 0 and put it into the 'checkout' ParamDef
- *
- * If we want, we can check out CHECK_INPUT, or any other parameter. For example,
- * to do a visual echo, we just check out CHECK_INPUT at (in_data->current_time -
- * delay_time) and blend it in using the PF_BLEND callback.
- */
- err = PF_CHECKOUT_PARAM(in_data, CHECK_LAYER,
- frame, 0,
- 30, &checkout);
-
- if (!err) {
- if (checkout.u.ld.data) {
-
- /* An actual valid layer. Copy the checked-out layer into the top half
- * of the output buffer, squeezing or stretching it as needed.
- */
- err = PF_COPY(&checkout.u.ld, output, NULL, &halfsies);
-
- } else {
-
- /* checkout.u.ld.data is NULL, meaning that the 'NONE' layer was selected.
- * In this case, I'll fill the top half with zero-alpha black (send NULL
- * for the color.)
- */
- err = PF_FILL(NULL, &halfsies, output);
- }
-
- if (!err) {
- halfsies.top = halfsies.bottom;
- halfsies.bottom = output->height;
-
- /* Set the 'halfsies' rectangle to be the bottom half and copy the
- * source layer into the bottom half, squeezing or stretching it as needed.
- */
- err = PF_COPY(¶ms[CHECK_INPUT]->u.ld, output, NULL, &halfsies);
-
- }
-
- /* Note that I'm checking in the 'checkout' param even if an error has occurred
- * since the checkout. It is very important to check in all parameters you've checked
- * out. (Errors are not necessarily something bad... a user cancel is sent back
- * from the PF callbacks as an error.) Be careful to respond to all the error codes
- * sent back from PF routines -- interruptibility may be degraded otherwise.
- */
- err2 = PF_CHECKIN_PARAM(in_data, &checkout);
- if (!err) err = err2;
- }
-
- return err;
- }
-
-
- PF_Err main (
- PF_Cmd cmd,
- PF_InData *in_data,
- PF_OutData *out_data,
- PF_ParamDef *params[],
- PF_LayerDef *output )
- {
- PF_Err err = PF_Err_NONE;
- EnterCodeResource(); /* only available in CodeWarrior */
-
- switch (cmd) {
- case PF_Cmd_ABOUT:
- err = About(in_data,out_data,params,output);
- break;
- case PF_Cmd_GLOBAL_SETUP:
- err = GlobalSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_PARAMS_SETUP:
- err = ParamsSetup(in_data,out_data,params,output);
- break;
- case PF_Cmd_RENDER:
- err = Render(in_data,out_data,params,output);
- break;
-
- default:
- break;
- }
-
- ExitCodeResource();
-
- return err;
- }
-